home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / ListItem.java < prev    next >
Text File  |  1998-08-21  |  2KB  |  89 lines

  1. package symantec.itools.awt;
  2.  
  3.  
  4. import java.awt.Image;
  5. import java.awt.Color;
  6. import java.awt.FontMetrics;
  7. import java.net.URL;
  8.  
  9. //  07/29/87    CAR class implements java.io.Serializable
  10. //                  marked fields transient as needed
  11. //                  added field "url" to keep track of the URL "behind" the Image (if one is provieded)
  12. //                  added constructor which takes an URL as one of its arguments
  13.  
  14.  
  15. /**
  16.  * This class is not public and therefore cannot be used outside this package.
  17.  *
  18.  * @see ImageListBox
  19.  *
  20.  * @version 1.0, Nov 26, 1996
  21.  *
  22.  * @author    Symantec
  23.  *
  24.  */
  25.  
  26.  
  27. class ListItem implements java.io.Serializable
  28. {
  29.     URL                 url = null;
  30.     transient Image     image;
  31.     String              sText;
  32.     boolean             bEnabled;
  33.     boolean             bSelected;
  34.     transient boolean   bDirty;
  35.     Color               color;
  36.     int                 lineWidth;
  37.     boolean             bCellBorder;
  38.     Color               cellBorderColor;
  39.     boolean             bEdited = false;
  40.  
  41.     public ListItem(Image image, String sText, boolean bEnabled, FontMetrics fm, boolean bCellBorder)
  42.     {
  43.         this.image = image;
  44.         this.sText = sText;
  45.         this.bEnabled = bEnabled;
  46.         this.bSelected = false;
  47.         this.bDirty = true;
  48.         this.color = null;
  49.         this.bCellBorder = bCellBorder;
  50.         this.cellBorderColor = Color.black;
  51.         updateWidth(fm);
  52.     }
  53.  
  54.     public ListItem(Image image, URL url, String sText, boolean bEnabled, FontMetrics fm, boolean bCellBorder)
  55.     {
  56.         this(image, sText, bEnabled, fm, bCellBorder);
  57.         this.url = url;
  58.     }
  59.  
  60.     public void updateWidth(FontMetrics fm)
  61.     {
  62.         if (fm != null)
  63.             this.lineWidth = fm.stringWidth(sText);
  64.         else
  65.             this.lineWidth = 0;
  66.     }
  67.  
  68.     public String toString()
  69.     {
  70.           String s = "ListItem " + sText;
  71.           if (image != null)
  72.               s += " [Image]";
  73.           if (color != Color.black)
  74.               s += " [Colored]";
  75.           if (bEnabled)
  76.               s += " [Enabled]";
  77.           else
  78.               s += " [Disabled]";
  79.           if (bSelected)
  80.               s += " [Selected]";
  81.           else
  82.               s += " [Not Selected]";
  83.           if (bDirty)
  84.               s += " [Dirty]";
  85.         return s;
  86.     }
  87. }
  88.  
  89.